package com.controller;

import com.pojo.Curriculum;
import com.service.CurriculumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/curriculum")
@CrossOrigin
public class CurriculumController {
    @Autowired
    CurriculumService service;

    public static final int PAGE_SIZE = 7;
    @GetMapping("/findAll")
    public @ResponseBody List findAll(Integer page){
        int startRow = 0;
        if(page != null){
            startRow = (page-1)*PAGE_SIZE;
        }
        return service.selectFindAll(startRow,PAGE_SIZE);
    }

    @GetMapping("/getCount")
    public @ResponseBody int getCount(){
        return service.getCount();
    }
}
